﻿@namespace AntDesign
@inherits AntInputComponentBase<string>

@using AntDesign.Internal

<div @ref="@_divRef" style="@Style" id="@Id">
    <CascadingValue Value='$"ant-select-dropdown"' Name="PrefixCls">
        <OverlayTrigger Style="display: inline"
                        Visible="@(ShowPanel && !_isOptionsZero)"
                        IsButton="@true"
                        Disabled="false"
                        Trigger="new TriggerType[] { TriggerType.Click }"
                        OverlayEnterCls="slide-up-enter slide-up-enter-active slide-up"
                        OverlayLeaveCls="slide-up-leave slide-up-leave-active slide-up"
                        OverlayClassName="@OverlayClassName"
                        OverlayStyle="@OverlayStyle">
            <Overlay>
                <CascadingValue Value="this">
                    <div style="max-height: 256px; overflow-y: auto; overflow-anchor: none; @_minWidth">
                        <div style="display: flex;flex-direction: column;">
                            @if (Options.Value != null)
                            {
                                foreach (var option in GetOptionItems())
                                {
                                    <AutoCompleteOption Value="@option.Value" Label="@option.Label" Disabled="option.IsDisabled">
                                        @option.Label
                                    </AutoCompleteOption>
                                }
                            }
                            else
                            {
                                @AutoCompleteOptions
                            }
                        </div>
                    </div>
                </CascadingValue>
            </Overlay>
            <ChildContent>
                <CascadingValue Value="this">
                    @if (ChildContent == null)
                    {
                        <AutoCompleteInput @bind-Value="@CurrentValue" />
                    }
                    else
                    {
                        @ChildContent
                    }
                </CascadingValue>
            </ChildContent>
        </OverlayTrigger>
    </CascadingValue>
</div>